use ::persistence::sqlx_p::DB;
use sqlx::{postgres::PgRow, Row};

pub mod outbound_persis;
pub mod persistence;

///从数据库判定是否具有指定转接号码
pub async fn phone_nodedtl_is_sip_num(name: &str) -> bool {
	let sql =
		"select count(*)::int as count from pt_phone_nodedtl where turn_num = $1 and is_sip = 1";
	let r = sqlx::query(sql)
		.bind(name)
		.map(|r: PgRow| r.try_get("count").unwrap_or(0))
		.fetch_one(&DB.pool)
		.await;
	
	match r {
		Ok(r) => r > 0,
		Err(_) => false,
	}
}

